package com.example.librarymanagementproject2.web.controller;

import com.example.librarymanagementproject2.Common.config.ResultVO;
import com.example.librarymanagementproject2.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName EmailController
 * @Description TODO
 * @Author Kx
 * @Date 2025/10/17 11:09
 * @Version 1.0
 */
@RestController
public class EmailController {
    /**
     * 邮箱发送工具对象
     */
    @Autowired
    private JavaMailSender javaMailSender;
    @Autowired
    private EmailService emailService;

    /**
     * @author: kx
     * @date: 2025/10/20 20:15
     * @param recipientEmail : 接收用户邮箱
     * @return com.example.librarymanagementproject2.Common.config.ResultVO<java.lang.String>
     * @description: 发送邮件
    */
    @PostMapping("/email/{email}")
    public ResultVO<String> sendEmail(@PathVariable("email") String recipientEmail) {
        emailService.insertEmailSendRecord(recipientEmail);
        return ResultVO.success("发送成功");
    }
}
